<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SHOP 管理中心 - 属性管理 </title>
<base href="__STATIC__/Admin/">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1>
<span class="action-span"><a href="{:url('Admin/Attribute/attr_list')}">商品属性</a></span>
<span class="action-span1"><a href="index.php?act=main">SHOP 管理中心</a> </span><span id="search_id" class="action-span1"> - 添加属性 </span>
<div style="clear:both"></div>
</h1>

<div class="main-div">
  <form action="{:url('Admin/Attribute/attr_add')}" method="post" name="theForm">
  <table width="100%" id="general-table">
      <tbody><tr>
        <td class="label">属性名称：</td>
        <td>
          <input type="text" name="attr_name" value="" size="30">
            <span class="require-field">*</span>        
        </td>
      </tr>
      <tr>
        <td class="label">所属商品类型：</td>
        <td>
          <select name="cat_id" id="sel">
          <option value="0">请选择...</option>
          {foreach $type as $v}
            <option value="{$v.type_id}">{$v.type_name}</option>
          {/foreach}
          </td>
      </tr>
      <tr id="attrGroups" style="display: none;">
        <td class="label">属性分组：</td>
        <td>
          <select name="attr_group" id="attr_group"> 
          </select>
        </td>
      </tr> 
      <tr>
        <td class="label">该属性值的录入方式：</td>
        <td>
          <input type="radio" name="attr_input_type" value="0" checked=''>手工录入          
          <input type="radio" name="attr_input_type" value="1" class="check">从下面的列表中选择（一行代表一个可选值）                
        </td>
      </tr>
      <tr>
        <td class="label">可选值列表：</td>
        <td>
          <textarea name="attr_values" cols="30" rows="5" disabled='true' id="toggle"></textarea>
        </td>
      </tr>
      <tr>
        <td colspan="2">
        <div class="button-div">
          <input type="submit" value=" 确定 " class="button">
          <input type="reset" value=" 重置 " class="button">
        </div>
        </td>
      </tr>
      </tbody></table>
    <input type="hidden" name="act" value="insert">
    <input type="hidden" name="attr_id" value="0">
  </form>
</div>

<div id="footer">
	版权所有 &copy; 2006-2013 软工教育 - 高级PHP - </div>
</div>

</body>
<script src="jquery.js"></script>
<script>

  $(":radio").on('click',function(){
      var checked = $('input:radio[name="attr_input_type"]:checked').val();
      if(checked == 1){
        $("#toggle").attr("disabled",false);
      }else if(checked == 0){
        $("#toggle").attr("disabled",true);
      }

  });

  $("#sel").on('change',function(){
        var id = $(this).val();
        $.ajax({
            url:"{:url('Admin/GoodsType/GoodsType_check')}",
            data:{id:id},
            dataType:'json',
            success:function(e){
              var arr = e.data;
              var str = '';
               if(e.code==1){
                 $("#attr_group").empty();
                  $("#attrGroups").show();
                  for(var i=0;i<arr.length;i++){
                    str += '<option value="'+i+'">'+arr[i]+'</option>';
                  }
                   $("#attr_group").append(str);
               }else{
                  $("#attrGroups").hide();
               }
            }
        });
  });
</script>
</html>